// app.js
const express = require('express');
const apiRouter = require('./routes/api');

const app = express();

app.use(express.json());
app.use('/api', apiRouter);

// 错误处理中间件
app.use((err, req, res, next) => {
    console.error(err.stack);
    res.status(500).json({ error: '服务器错误' });
});

module.exports = app;